package name.fowler.refactoring.simplestore;

public abstract class Rental {
	private Movie m_Movie;
	private int m_DaysRented;

	public Rental(Movie movie, int daysRented) {
		m_Movie = movie;
		m_DaysRented = daysRented;
	}

	public int getDaysRented() {
		return m_DaysRented;
	}

	public Movie getMovie() {
		return m_Movie;
	}

	public abstract double getAmount();
	
	boolean needAdditionalFrequentPoints() {
		return false;
	}

	public static Rental createRental(Movie movie, int daysRented) throws RuntimeException{
		switch(movie.getPriceCode()) {
		case Regular:
			return new RegularRental(movie, daysRented);
		case NewRelease:
			return new NewReleaseRental(movie, daysRented);
		case Childrens:
			return new ChildrensRental(movie, daysRented);
		default:
			throw new RuntimeException("Unexpected format");
		}
	}
}

